
#include "../SGD Wrappers/SGD_Geometry.h"

#include "../SGD Wrappers/SGD_AudioManager.h"
#include "../SGD Wrappers/SGD_GraphicsManager.h"

#include "../Message/DestroyEntityMessage.h"

#include "../source/Game.h"

#include "SniperBullet.h"

SniperBullet::SniperBullet(float posX, float posY
	, Entity* owner)
{
	SetOwnerType(owner); 
	SetPosition(owner->GetPosition());
	SetSize({ 4, 4 }); 
	SetSpeed(500); 
	SetDamage(50);
	SetFinalSound(Game::GetInstance()->GetSniperBulletSfx()); 
	SetHasCollided(false); 
	//SetImage(); 
	SetRotation(0);
	SetVelocity({ 0, -1 }); 
	SetTimer(0.05f); 
}


//Interface
void SniperBullet::Update(float dt)
{
	SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance(); 
	m_fTimer -= dt; 

	if (m_fTimer < 0.0f)
	{
		SetOwnerType(nullptr); 
		DestroyEntityMessage* entityToDestroy =
			new DestroyEntityMessage(this); 
		entityToDestroy->QueueMessage(); 
		entityToDestroy = nullptr; 
	}

	if (!pAudio->IsAudioPlaying(GetFinalSound()))
	{
		pAudio->PlayAudio(GetFinalSound());
	}

}

void SniperBullet::Render()
{

}

void SniperBullet::HandleCollision(const IEntity* pOther)
{

}

void SniperBullet::HandleEvent()
{

}

SGD::Rectangle SniperBullet::GetRect() const
{
	return SGD::Rectangle
	{
		m_ptPosition - m_szSize * 0.5f, 
		m_ptPosition + m_szSize * 0.5f
	};
}

